Skip to content

feat: Add Upload with v2 API#595

Open
LouisCAD wants to merge 33 commits intoprotected/v2from
upload-v2
Open

feat: Add Upload with v2 API#595
LouisCAD wants to merge 33 commits intoprotected/v2from
upload-v2

Conversation

@LouisCAD
Copy link
Contributor

@LouisCAD LouisCAD commented Mar 3, 2026

Will need an update to the KMP library.

LouisCAD added 8 commits March 3, 2026 17:53
Uses Splitties Preferences to observe shared preferences,
and access it off the main thread.
This commit also:
- Introduces middle interfaces (UploadSessionStarter & TransferUploader)
- Adds AbandonedTransferCleanupWorker
- Updates SwissTransferInjectionModule to support these
- Prepares support for transfer titles
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for starting and performing uploads via the SwissTransfer v2 API while keeping the legacy v1 upload flow available, and updates surrounding app plumbing (account/onboarding prefs, URL building, cleanup workers) to accommodate the dual-stack upload pipeline.

Changes:

  • Introduces v2 upload session start + v2 transfer uploader, and routes upload execution based on whether the session destination is v1 or v2 (Xor).
  • Adds a v2 “abandoned transfer” cleanup worker and integrates it into the upload failure/cancel path.
  • Extends transfer/new-transfer models (e.g., title, linkId, apiSource) and updates UI/viewmodels/previews accordingly.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
app/src/test/java/com/infomaniak/swisstransfer/TransferSectionGroupingTest.kt Updates test fixture for new TransferUi fields.
app/src/main/java/com/infomaniak/swisstransfer/upload/UploadSessionStarterV2.kt Adds v2 session starter using UploadV2Manager.
app/src/main/java/com/infomaniak/swisstransfer/upload/UploadSessionStarterV1.kt Refactors v1 starter to extend shared UploadSessionStarter and return an Xor.
app/src/main/java/com/infomaniak/swisstransfer/upload/UploadSessionStarterInterface.kt Introduces shared abstraction + unified Result contract for v1/v2 session start.
app/src/main/java/com/infomaniak/swisstransfer/upload/UploadSessionManager.kt Chooses v1/v2 uploader based on destination and adjusts URL + cleanup scheduling.
app/src/main/java/com/infomaniak/swisstransfer/upload/TransferUploaderV2.kt New v2 chunk uploader and finalize flow (including link UUID).
app/src/main/java/com/infomaniak/swisstransfer/upload/TransferUploaderInterface.kt New shared uploader interface + UploadResult (transferId/linkId).
app/src/main/java/com/infomaniak/swisstransfer/upload/TransferUploader.kt Renames legacy uploader to TransferUploaderV1 and adapts to interface/result type.
app/src/main/java/com/infomaniak/swisstransfer/upload/NewTransferParamsExt.kt Passes title into the upload session request.
app/src/main/java/com/infomaniak/swisstransfer/upload/NewTransferParams.kt Adds nullable title to new transfer params.
app/src/main/java/com/infomaniak/swisstransfer/upload/AbandonedTransferV2CleanupWorker.kt Adds v2 cleanup worker to cancel abandoned v2 transfers.
app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountUtils.kt Reworks activation to sync Sentry user + load KMP user based on onboarding state.
app/src/main/java/com/infomaniak/swisstransfer/ui/utils/AccountPreferences.kt Migrates to Splitties Preferences + adds isOnboardingDoneFlow migration logic.
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/newtransfer/pickfiles/PickFilesViewModel.kt Adds transfer title state and includes it in NewTransferParams.
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/transferdetails/TransferDetailsViewModel.kt Treats PENDING_UPLOAD as loading.
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsValidityPeriodScreen.kt Uses ValidityPeriod.days for pluralization.
app/src/main/java/com/infomaniak/swisstransfer/ui/screen/main/settings/SettingsScreen.kt Uses ValidityPeriod.days for display.
app/src/main/java/com/infomaniak/swisstransfer/ui/previewparameter/GroupedTransfersPreviewParameterProvider.kt Updates preview data for linkId and apiSource.
app/src/main/java/com/infomaniak/swisstransfer/ui/OnboardingActivity.kt Writes onboarding completion via new AccountPreferences accessor.
app/src/main/java/com/infomaniak/swisstransfer/ui/MainApplication.kt Initializes Splitties appCtx + core network config earlier; activates AccountUtils.
app/src/main/java/com/infomaniak/swisstransfer/ui/LaunchActivity.kt Writes onboarding flag via new AccountPreferences accessor.
app/src/main/java/com/infomaniak/swisstransfer/di/SwissTransferInjectionModule.kt Provides v1/v2 upload managers and selects the proper UploadSessionStarter.
app/src/main/java/com/infomaniak/swisstransfer/di/ApplicationModule.kt Adjusts login appUID and adds a logcat callback for login issues.
app/build.gradle.kts Adds Splitties preferences dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +66
private fun isBeyondBackedAutoCleanup(): Boolean {
val requestUtcTimestampMillis = inputData.getLong(DataKeys.REQUEST_UTC_TIMESTAMP_MILLIS, 0L)
val giveUpUtcTimestampMillis = requestUtcTimestampMillis + backendAutoCleanupDelay.inWholeMilliseconds
return System.currentTimeMillis() >= giveUpUtcTimestampMillis
}

override suspend fun doWork(): Result {
if (isBeyondBackedAutoCleanup()) return Result.failure()
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method name isBeyondBackedAutoCleanup looks like a typo ("Backed" vs "Backend"), especially given backendAutoCleanupDelay below. Consider renaming to something like isBeyondBackendAutoCleanup for clarity/searchability.

Suggested change
private fun isBeyondBackedAutoCleanup(): Boolean {
val requestUtcTimestampMillis = inputData.getLong(DataKeys.REQUEST_UTC_TIMESTAMP_MILLIS, 0L)
val giveUpUtcTimestampMillis = requestUtcTimestampMillis + backendAutoCleanupDelay.inWholeMilliseconds
return System.currentTimeMillis() >= giveUpUtcTimestampMillis
}
override suspend fun doWork(): Result {
if (isBeyondBackedAutoCleanup()) return Result.failure()
private fun isBeyondBackendAutoCleanup(): Boolean {
val requestUtcTimestampMillis = inputData.getLong(DataKeys.REQUEST_UTC_TIMESTAMP_MILLIS, 0L)
val giveUpUtcTimestampMillis = requestUtcTimestampMillis + backendAutoCleanupDelay.inWholeMilliseconds
return System.currentTimeMillis() >= giveUpUtcTimestampMillis
}
override suspend fun doWork(): Result {
if (isBeyondBackendAutoCleanup()) return Result.failure()

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch.

//TODO[Sentry]: Should we forward this to Sentry, or leave it only in logcat for debug?
val tag = "LoginIssue"
Log.e(tag, message)
Log.e(tag, extras.toString())
Copy link

Copilot AI Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentryCallback currently logs extras.toString() to logcat. Depending on what extras contains (tokens, user identifiers, URLs), this can leak sensitive information on production devices. Consider guarding this behind BuildConfig.DEBUG, redacting known-sensitive keys/values, or sending a sanitized event to Sentry instead of raw logcat output.

Suggested change
Log.e(tag, extras.toString())
if (BuildConfig.DEBUG) {
Log.e(tag, extras.toString())
}

Copilot uses AI. Check for mistakes.
@sirambd sirambd enabled auto-merge March 6, 2026 13:23
@sirambd sirambd disabled auto-merge March 6, 2026 13:27
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants